import 'dart:core';

import 'package:json_annotation/json_annotation.dart';

part 'consult.g.dart';

/// @Author lixiaobin
/// @Date 2024/2/21
/// @Description
@JsonSerializable(explicitToJson: true)
class ConsultModel {
  String? id;
  String? createId;
  String? createBy;

  //"status": "业务状态（0：待支付，1：待处理，2：已完成，3：会话中，4：超时未处理，5：取消预约订单，6.医生拒绝，7未接诊）",
  String? status;
  String? patientName;
  String? name;
  String? patientAge;
  String? age;
  String? sex;
  String? patientId;
  String? patientIdcardId;
  String? idcardId;
  String? doctorName;
  String? doctorId;
  String? price;
  String? orderTime;
  String? endTime;
  String? actualEndTime;
  String? illDescribe;
  String? illnessDesc;
  String? illInfo;
  String? illnessImg;
  String? endFeedback;
  String? createTime;
  String? updateTime;
  String? patientHeadIcon;
  String? type;
  String? literatureType;
  String? pharmacyPhone;
  String? startTime;
  String? approveName;
  String? approveId;
  String? signId;
  String? signName;
  String? patientPhone;
  String? prescriptionNo;
  String? pharmacyId;
  String? isSign;
  String? details;
  String? attachment;
  String? pharmacyName;
  String? consultNum;
  bool? preview;
  bool? fromRecent;
  bool? inActivity;
  int? consultationType;
  String? consultationPhone;

  // List<Consultation> consultations;
  String? isOrder;
  bool? expried;
  String? sessionId;
  String? imSessionId;
  String? refund;
  String? doctorPhone;
  String? refuseConsult;
  String? patientSex;
  String? statusText;
  int? consultLength;
  String? promotionChannel;

  String? getStatusText() {
    if (status != null) {
      switch (status) {
        case "0":
          statusText = "待支付";
          break;
        case "1":
          statusText = "待处理";
          break;
        case "2":
          statusText = "已结束";
          break;
        case "3":
          statusText = "咨询中";
          break;
        case "4":
          statusText = "超时未处理";
          break;
        case "5":
          statusText = "取消预约订单";
          break;
        case "6":
          statusText = "医生拒绝";
          break;
        default:
          break;
      }
    }
    return statusText;
  }

  static String getPatientName(ConsultModel? consultModel) {
    var patientName = consultModel?.patientName ?? '';
    return (patientName).length > 3 ? '${patientName.substring(0, 3)}***' : patientName;
  }

  static ConsultModel fromJson(Map<String, dynamic> srcJson) => _$ConsultModelFromJson(srcJson);

  Map<String, dynamic> toJson() => _$ConsultModelToJson(this);
}
